<!--
 * @Author: wangshiyang
 * @Date: 2023-06-15 16:47:44
 * @LastEditors: wangshiyang
 * @LastEditTime: 2023-06-15 16:47:47
 * @Description: 请填写简介
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css" rel="stylesheet">
    <script src="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js"></script>
    <script src='https://unpkg.com/@antv/l7'></script>
    <style>
        html,
        body {
            overflow: hidden;
            margin: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script>
        mapboxgl.accessToken = 'pk.eyJ1IjoiY2hlbmdiZW5jaGFvIiwiYSI6ImNsODU3aGRiODA0Y2UzcHBzZmFlcmdqZ2sifQ.8k59W_pB_Riwe6o-MneRlA'
        const scene = new L7.Scene({
            id: 'map',
            map: new L7.Mapbox({
                style: 'mapbox://styles/mapbox/streets-v11',
                center: [114, 30],
                zoom: 12,
                projection: 'globe'
            })
        });
        const map = scene.map;
        map.on('load', () => {
            // geolocate.trigger();
            const geolocation = navigator.geolocation;
            geolocation.getCurrentPosition(res => {
                let { longitude, latitude } = res.coords;
                map.flyTo({
                    center:[longitude,latitude]
                })
               var marker = new mapboxgl.Marker({
                draggable: true
               }).setLngLat([longitude,latitude])
               marker.addTo(map);
            })

        });
        map.on("style.load", () => {
            map.setFog({

            });
        })
    </script>
</body>

</html>
